<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('任务列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>任务名：</label>
                                <input type="text" name="missionName"/>
                            </li>
                            <li>
<!--                                <label>1. 仅一次 2. 每日 3. 每周 4. 每月：</label>-->
<!--                                <input type="text" name="missionCycle"/>-->
                                <label>任务周期：</label>
                                <select name="missionCycle" th:with="type=${@dict.getType('sys_mission_cycle')}">
                                    <option value="" selected>所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
<!--                            <li>-->
<!--                                <label>针对仅一次的，设置任务执行日期：</label>-->
<!--                                <input type="text" class="time-input" placeholder="请选择针对仅一次的，设置任务执行日期" name="missionDate"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>巡检任务开始：时，分：</label>-->
<!--                                <input type="text" name="missionStartTime"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>巡检任务结束：时，分：</label>-->
<!--                                <input type="text" name="missionEndTime"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>星期几，0代表星期天：</label>-->
<!--                                <input type="text" name="missionWeekday"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>几号，1-31：</label>-->
<!--                                <input type="text" name="missionMonthday"/>-->
<!--                            </li>-->
                            <li>
<!--                                <label>任务状态：0. 暂停 1. 正常：</label>-->
<!--                                <select name="missionStatus">-->
<!--                                    <option value="">所有</option>-->
<!--                                    <option value="-1">代码生成请选择字典属性</option>-->
<!--                                </select>-->
                                <label>任务状态：</label>
                                <select name="missionStatus" th:with="type=${@dict.getType('sys_mission_status')}">
                                    <option value="" selected>所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:mission:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:mission:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:mission:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:mission:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:mission:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:mission:remove')}]];
        var prefix = ctx + "system/mission";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "任务",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'missionId',
                    title: '巡检任务索引',
                    visible: false
                },
                {
                    field: 'missionName',
                    title: '巡检任务名'
                },
                {
                    field: 'missionCycle',
                    title: '巡检周期',
                    formatter: function (value,row,index) {
                        switch (value) {
                            case 1: return "仅一次";
                            case 2: return "每日";
                            case 3: return "每周";
                            case 4: return "每月";
                        }
                    }
                },
                {
                    field: 'missionDate',
                    title: '巡检日期'
                },
                {
                    field: 'missionStartTime',
                    title: '开始时刻'
                },
                {
                    field: 'missionEndTime',
                    title: '结束时刻'
                },
                {
                    field: 'missionWeekday',
                    title: '每周几',
                    formatter: function (value,row,index) {
                        switch (value) {
                            case 1: return "每周一";
                            case 2: return "每周二";
                            case 3: return "每周三";
                            case 4: return "每周四";
                            case 5: return "每周五";
                            case 6: return "每周六";
                            case 0: return "每周日";
                        }
                    }
                },
                {
                    field: 'missionMonthday',
                    title: '每月几号',
                    // formatter: function (value,row,index) {
                    //     if(null!=value && ""==value){
                    //         return value+"号";
                    //     }
                    // }
                },
                {
                    field: 'missionStatus',
                    title: '任务状态',
                    formatter: function (value,row,index) {
                        if(value==1){
                            return "正常";
                        }
                        else{
                            return "暂停";
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.missionId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.missionId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>